/***********************************************************************

	This file is part of KEEL-software, the Data Mining tool for regression, 
	classification, clustering, pattern mining and so on.

	Copyright (C) 2004-2010
	
	F. Herrera (herrera@decsai.ugr.es)
    L. Sánchez (luciano@uniovi.es)
    J. Alcalá-Fdez (jalcala@decsai.ugr.es)
    S. García (sglopez@ujaen.es)
    A. Fernández (alberto.fernandez@ujaen.es)
    J. Luengo (julianlm@decsai.ugr.es)

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see http://www.gnu.org/licenses/
  
**********************************************************************/

package keel.GraphInterKeel.datacf;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.File;
import java.net.MalformedURLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JToolBar;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import keel.GraphInterKeel.datacf.help.HelpContent;
import keel.GraphInterKeel.datacf.help.HelpFrame;
import keel.GraphInterKeel.datacf.editData.EditPanel;
import keel.GraphInterKeel.datacf.exportData.ExportPanel;
import keel.GraphInterKeel.datacf.importData.ImportPanel;
import keel.GraphInterKeel.datacf.partitionData.PartitionPanel;
import keel.GraphInterKeel.datacf.util.ButtonTabComponent;
import keel.GraphInterKeel.datacf.visualizeData.VisualizePanel;

/**
 * <p>
 * @author Written by Juan Carlos FernÃ¡ndez and Pedro Antonio GutiÃ©rrez (University of CÃ³rdoba) 23/10/2008
 * @version 1.0
 * @since JDK1.5
 * </p>
 */
public class DataCFFrame extends javax.swing.JFrame {

    /**
     * <p>
     * This is the main frame of Data Constructing and Formatting KEEL module
     * </p>
     */

    /**
     * <p>
     * Constructor that initializes the frame
     * </p>
     */
    public DataCFFrame() {
        initComponents();
        this.setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/keel/GraphInterKeel/resources/ico/logo/logo.png")));
    }

    /**
     * <p>
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     * </p>
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        mainPanel = new javax.swing.JPanel();
        verticalSplitPane = new javax.swing.JSplitPane();
        workPanel = new javax.swing.JPanel();
        selectorToolBar = new javax.swing.JToolBar();
        importjButton = new javax.swing.JButton();
        exportjButton = new javax.swing.JButton();
        visualizejButton = new javax.swing.JButton();
        editionjButton = new javax.swing.JButton();
        partitionjButton = new javax.swing.JButton();
        helpButton = new javax.swing.JButton();
        selectorTabbedPane = new javax.swing.JTabbedPane();
        startPanel = new javax.swing.JPanel();
        buttonPanel = new javax.swing.JPanel();
        exportjButton2 = new javax.swing.JButton();
        editjButton2 = new javax.swing.JButton();
        partitionjButton2 = new javax.swing.JButton();
        visualizejButton2 = new javax.swing.JButton();
        importjButton2 = new javax.swing.JButton();
        helpButton2 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        helpAuxPanel = new javax.swing.JPanel();
        helpTabbedPane = new javax.swing.JTabbedPane();
        statusPanel = new javax.swing.JPanel();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Data Constructing & Formatting");
        setMinimumSize(new java.awt.Dimension(800, 730));
        setName("Form"); // NOI18N
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        mainPanel.setMinimumSize(new java.awt.Dimension(333, 333));
        mainPanel.setName("mainPanel"); // NOI18N

        verticalSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        verticalSplitPane.setMinimumSize(new java.awt.Dimension(333, 333));
        verticalSplitPane.setName("verticalSplitPane"); // NOI18N

        workPanel.setMinimumSize(new java.awt.Dimension(680, 508));
        workPanel.setName("workPanel"); // NOI18N

        selectorToolBar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        selectorToolBar.setFloatable(false);
        selectorToolBar.setOrientation(javax.swing.SwingConstants.VERTICAL);
        selectorToolBar.setRollover(true);
        selectorToolBar.setName("selectorToolBar"); // NOI18N

        importjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/import.png"))); // NOI18N
        importjButton.setText("Import");
        importjButton.setToolTipText("Import Data");
        importjButton.setFocusable(false);
        importjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        importjButton.setIconTextGap(0);
        importjButton.setName("importjButton"); // NOI18N
        importjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        importjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                importjButtonActionPerformed(evt);
            }
        });
        selectorToolBar.add(importjButton);

        exportjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/export.png"))); // NOI18N
        exportjButton.setText("Export");
        exportjButton.setToolTipText("Export Data");
        exportjButton.setFocusable(false);
        exportjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        exportjButton.setIconTextGap(0);
        exportjButton.setName("exportjButton"); // NOI18N
        exportjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        exportjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exportjButtonActionPerformed(evt);
            }
        });
        selectorToolBar.add(exportjButton);

        visualizejButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/visualize.png"))); // NOI18N
        visualizejButton.setText("Visualize");
        visualizejButton.setToolTipText("Visualize Data");
        visualizejButton.setFocusable(false);
        visualizejButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        visualizejButton.setIconTextGap(0);
        visualizejButton.setName("visualizejButton"); // NOI18N
        visualizejButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        visualizejButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visualizejButtonActionPerformed(evt);
            }
        });
        selectorToolBar.add(visualizejButton);

        editionjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/edit.png"))); // NOI18N
        editionjButton.setText("Edit");
        editionjButton.setToolTipText("Edit Data");
        editionjButton.setFocusable(false);
        editionjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editionjButton.setIconTextGap(0);
        editionjButton.setName("editionjButton"); // NOI18N
        editionjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editionjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editionjButtonActionPerformed(evt);
            }
        });
        selectorToolBar.add(editionjButton);

        partitionjButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/partition.png"))); // NOI18N
        partitionjButton.setText("Partition");
        partitionjButton.setToolTipText("Make Partitions");
        partitionjButton.setFocusable(false);
        partitionjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        partitionjButton.setIconTextGap(0);
        partitionjButton.setName("partitionjButton"); // NOI18N
        partitionjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        partitionjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                partitionjButtonActionPerformed(evt);
            }
        });
        selectorToolBar.add(partitionjButton);

        helpButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/help.png"))); // NOI18N
        helpButton.setText("Help");
        helpButton.setToolTipText("Outline Help");
        helpButton.setFocusable(false);
        helpButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        helpButton.setIconTextGap(0);
        helpButton.setName("helpButton"); // NOI18N
        helpButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        helpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                helpButtonActionPerformed(evt);
            }
        });
        selectorToolBar.add(helpButton);

        selectorTabbedPane.setMinimumSize(new java.awt.Dimension(412, 400));
        selectorTabbedPane.setName("selectorTabbedPane"); // NOI18N
        selectorTabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                selectorTabbedPaneStateChanged(evt);
            }
        });

        startPanel.setMinimumSize(new java.awt.Dimension(412, 200));
        startPanel.setName("startPanel"); // NOI18N

        buttonPanel.setMinimumSize(new java.awt.Dimension(600, 200));
        buttonPanel.setName("buttonPanel"); // NOI18N
        buttonPanel.setLayout(new java.awt.GridBagLayout());

        exportjButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/64x64/export.png"))); // NOI18N
        exportjButton2.setText("<html><b>Export Data</b><hr>This option allows you to export KEEL format files to other formats.</html>");
        exportjButton2.setToolTipText("Export Data");
        exportjButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        exportjButton2.setIconTextGap(6);
        exportjButton2.setMargin(new java.awt.Insets(0, 5, 0, 5));
        exportjButton2.setMaximumSize(new java.awt.Dimension(200, 200));
        exportjButton2.setMinimumSize(new java.awt.Dimension(200, 200));
        exportjButton2.setName("exportjButton2"); // NOI18N
        exportjButton2.setPreferredSize(new java.awt.Dimension(160, 160));
        exportjButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        exportjButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exportjButton2ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        buttonPanel.add(exportjButton2, gridBagConstraints);

        editjButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/64x64/edit.png"))); // NOI18N
        editjButton2.setText("<html><b>Edit Data</b><hr>This option allows you to edit existing KEEL format datasets.</html>");
        editjButton2.setToolTipText("Edit Data");
        editjButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editjButton2.setIconTextGap(6);
        editjButton2.setMargin(new java.awt.Insets(0, 5, 0, 5));
        editjButton2.setMaximumSize(new java.awt.Dimension(200, 200));
        editjButton2.setMinimumSize(new java.awt.Dimension(200, 200));
        editjButton2.setName("editjButton2"); // NOI18N
        editjButton2.setPreferredSize(new java.awt.Dimension(160, 160));
        editjButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editjButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editjButton2ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        buttonPanel.add(editjButton2, gridBagConstraints);

        partitionjButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/64x64/partition.png"))); // NOI18N
        partitionjButton2.setText("<html><b>Make Partitions</b><hr>This option allows you to make partitions of existing KEEL datasets.</html>");
        partitionjButton2.setToolTipText("Make Partitions");
        partitionjButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        partitionjButton2.setIconTextGap(6);
        partitionjButton2.setMargin(new java.awt.Insets(0, 5, 0, 5));
        partitionjButton2.setMaximumSize(new java.awt.Dimension(200, 200));
        partitionjButton2.setMinimumSize(new java.awt.Dimension(200, 200));
        partitionjButton2.setName("partitionjButton2"); // NOI18N
        partitionjButton2.setPreferredSize(new java.awt.Dimension(160, 160));
        partitionjButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        partitionjButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                partitionjButton2ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        buttonPanel.add(partitionjButton2, gridBagConstraints);

        visualizejButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/64x64/visualize.png"))); // NOI18N
        visualizejButton2.setText("<html><b>Visualize Data</b><hr>This option allows you to visualize existing KEEL format datasets.</html>");
        visualizejButton2.setToolTipText("Visualize Data");
        visualizejButton2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        visualizejButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        visualizejButton2.setIconTextGap(6);
        visualizejButton2.setMargin(new java.awt.Insets(0, 5, 0, 5));
        visualizejButton2.setMaximumSize(new java.awt.Dimension(200, 200));
        visualizejButton2.setMinimumSize(new java.awt.Dimension(200, 200));
        visualizejButton2.setName("visualizejButton2"); // NOI18N
        visualizejButton2.setPreferredSize(new java.awt.Dimension(160, 160));
        visualizejButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        visualizejButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                visualizejButton2ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        buttonPanel.add(visualizejButton2, gridBagConstraints);

        importjButton2.setBackground(new java.awt.Color(255, 255, 255));
        importjButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/64x64/import.png"))); // NOI18N
        importjButton2.setText("<html><b>Import Data</b><hr>Import other file formats to KEEL or add datasets to the Experiments module.</html>");
        importjButton2.setToolTipText("Import Data");
        importjButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        importjButton2.setIconTextGap(6);
        importjButton2.setMargin(new java.awt.Insets(0, 5, 0, 5));
        importjButton2.setMaximumSize(new java.awt.Dimension(200, 200));
        importjButton2.setMinimumSize(new java.awt.Dimension(200, 200));
        importjButton2.setName("importjButton2"); // NOI18N
        importjButton2.setPreferredSize(new java.awt.Dimension(160, 160));
        importjButton2.setVerifyInputWhenFocusTarget(false);
        importjButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        importjButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                importjButton2ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        buttonPanel.add(importjButton2, gridBagConstraints);

        helpButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/64x64/help.png"))); // NOI18N
        helpButton2.setText("<html><b>Help</b><hr>This option shows you a complete manual of the application.</html>");
        helpButton2.setToolTipText("Outline Help");
        helpButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        helpButton2.setIconTextGap(6);
        helpButton2.setMargin(new java.awt.Insets(0, 5, 0, 5));
        helpButton2.setMaximumSize(new java.awt.Dimension(200, 200));
        helpButton2.setMinimumSize(new java.awt.Dimension(200, 200));
        helpButton2.setName("helpButton2"); // NOI18N
        helpButton2.setPreferredSize(new java.awt.Dimension(160, 160));
        helpButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        helpButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                helpButton2ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        buttonPanel.add(helpButton2, gridBagConstraints);

        jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getStyle() | java.awt.Font.BOLD, jLabel1.getFont().getSize()+15));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/keel/GraphInterKeel/resources/ico/datacf/64x64/logo.png"))); // NOI18N
        jLabel1.setText("KEEL: DATA CONSTRUCTING FORMATTING");
        jLabel1.setName("jLabel1"); // NOI18N

        javax.swing.GroupLayout startPanelLayout = new javax.swing.GroupLayout(startPanel);
        startPanel.setLayout(startPanelLayout);
        startPanelLayout.setHorizontalGroup(
            startPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 788, Short.MAX_VALUE)
            .addComponent(buttonPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 788, Short.MAX_VALUE)
        );
        startPanelLayout.setVerticalGroup(
            startPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(startPanelLayout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE))
        );

        selectorTabbedPane.addTab("START       ", startPanel);

        javax.swing.GroupLayout workPanelLayout = new javax.swing.GroupLayout(workPanel);
        workPanel.setLayout(workPanelLayout);
        workPanelLayout.setHorizontalGroup(
            workPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(workPanelLayout.createSequentialGroup()
                .addComponent(selectorToolBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(selectorTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE))
        );
        workPanelLayout.setVerticalGroup(
            workPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(selectorTabbedPane, 0, 0, Short.MAX_VALUE)
            .addComponent(selectorToolBar, javax.swing.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE)
        );

        verticalSplitPane.setLeftComponent(workPanel);

        helpAuxPanel.setName("helpAuxPanel"); // NOI18N

        helpTabbedPane.setMinimumSize(new java.awt.Dimension(0, 50));
        helpTabbedPane.setName("helpTabbedPane"); // NOI18N
        helpTabbedPane.setPreferredSize(new java.awt.Dimension(120, 50));
        helpTabbedPane.addTab("User Manual", contenido);

        javax.swing.GroupLayout helpAuxPanelLayout = new javax.swing.GroupLayout(helpAuxPanel);
        helpAuxPanel.setLayout(helpAuxPanelLayout);
        helpAuxPanelLayout.setHorizontalGroup(
            helpAuxPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 878, Short.MAX_VALUE)
            .addGroup(helpAuxPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(helpTabbedPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 878, Short.MAX_VALUE))
        );
        helpAuxPanelLayout.setVerticalGroup(
            helpAuxPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 149, Short.MAX_VALUE)
            .addGroup(helpAuxPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(helpTabbedPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE))
        );

        verticalSplitPane.setRightComponent(helpAuxPanel);

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(verticalSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 878, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(verticalSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        statusPanel.setMaximumSize(new java.awt.Dimension(333, 233333));
        statusPanel.setMinimumSize(new java.awt.Dimension(333, 0));
        statusPanel.setName("statusPanel"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setMaximumSize(new java.awt.Dimension(0, 5));
        statusAnimationLabel.setMinimumSize(new java.awt.Dimension(0, 5));
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N
        statusAnimationLabel.setPreferredSize(new java.awt.Dimension(0, 5));

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 854, Short.MAX_VALUE)
                .addComponent(statusAnimationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(665, Short.MAX_VALUE)
                .addComponent(statusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void importjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importjButtonActionPerformed
    addImportTab(true, true);
}//GEN-LAST:event_importjButtonActionPerformed

private void exportjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportjButtonActionPerformed
    addExportTab();
}//GEN-LAST:event_exportjButtonActionPerformed

private void visualizejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visualizejButtonActionPerformed
    addVisualizeTab();
}//GEN-LAST:event_visualizejButtonActionPerformed

private void editionjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editionjButtonActionPerformed
    addEditTab();
}//GEN-LAST:event_editionjButtonActionPerformed

private void partitionjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_partitionjButtonActionPerformed
    addPartitionTab();
}//GEN-LAST:event_partitionjButtonActionPerformed

private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpButtonActionPerformed
    help();
}//GEN-LAST:event_helpButtonActionPerformed

private void exportjButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportjButton2ActionPerformed
    addExportTab();
}//GEN-LAST:event_exportjButton2ActionPerformed

private void editjButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editjButton2ActionPerformed
    addEditTab();
}//GEN-LAST:event_editjButton2ActionPerformed

private void partitionjButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_partitionjButton2ActionPerformed
    addPartitionTab();
}//GEN-LAST:event_partitionjButton2ActionPerformed

private void visualizejButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visualizejButton2ActionPerformed
    addVisualizeTab();
}//GEN-LAST:event_visualizejButton2ActionPerformed

private void importjButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importjButton2ActionPerformed

    addImportTab(true, true);
}//GEN-LAST:event_importjButton2ActionPerformed

private void helpButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpButton2ActionPerformed
    help();
}//GEN-LAST:event_helpButton2ActionPerformed

private void selectorTabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_selectorTabbedPaneStateChanged
    // Get current tab
    Component sel = selectorTabbedPane.getSelectedComponent();
    if (sel instanceof VisualizePanel) {
        this.contenido.muestraURL(this.getClass().getResource("/help/data_view.html"));
    } else if (sel instanceof ImportPanel) {
        this.contenido.muestraURL(this.getClass().getResource("/help/data_import.html"));
    } else if (sel instanceof PartitionPanel) {
        this.contenido.muestraURL(this.getClass().getResource("/help/data_partition.html"));
    } else if (sel instanceof EditPanel) {
        this.contenido.muestraURL(this.getClass().getResource("/help/data_edit.html"));
    } else if (sel instanceof ExportPanel) {
        this.contenido.muestraURL(this.getClass().getResource("/help/data_export.html"));
    } else {
        this.contenido.muestraURL(this.getClass().getResource("/help/data_clear.html"));
    }
}//GEN-LAST:event_selectorTabbedPaneStateChanged

private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
    keel.GraphInterKeel.experiments.Experiments exp;
    if (this.parent != null) {
        this.parent.setVisible(true);
    }
    //if the parent of the frame is Experiments, then this windows has been invoked
    //to make partitions. Therefore, the Experiments.dinDatasets panel must be reloaded
    //to reflect those changes.
    if (this.parent instanceof keel.GraphInterKeel.experiments.Experiments) {
        //System.out.println("\t >>>>> Updating partitions from DataCF");
        exp = ((keel.GraphInterKeel.experiments.Experiments) this.parent);

        /**********  reload the modified XML  **********/
        //first, lets clear current data in the panels
        exp.panelDatasets.removeAllData();
        exp.dinDatasets.removeAllData();

        String root = "." + File.separatorChar + "data" +
                File.separatorChar + "Datasets.xml";
        File pathdata = new File(root);
        java.net.URL internalResource = null;
        try {
            internalResource = pathdata.toURL();
        } catch (MalformedURLException ex) {
            Logger.getLogger(DataCFFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
        exp.insertDirectoryData(internalResource, root);

        //sort the data sets by name
        exp.dinDatasets.sortDatasets();
        exp.panelDatasets.sortDatasets();

        //refresh the buttons in the panel
        exp.dinDatasets.reload(exp.experimentType());
        exp.panelDatasets.reload(exp.experimentType());

        //recover the previous active data sets
        exp.dinDatasets.reloadPreviousActiveDataSets();
        exp.panelDatasets.reloadPreviousActiveDataSets();
    }
}//GEN-LAST:event_formWindowClosing

    /**
     * Main Program
     *
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    // Set System L&F
                    UIManager.setLookAndFeel(
                            UIManager.getSystemLookAndFeelClassName());
                } catch (UnsupportedLookAndFeelException e) {
                    // handle exception
                } catch (ClassNotFoundException e) {
                    // handle exception
                } catch (InstantiationException e) {
                    // handle exception
                } catch (IllegalAccessException e) {
                    // handle exception
                }

                new DataCFFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel buttonPanel;
    private javax.swing.JButton editionjButton;
    private javax.swing.JButton editjButton2;
    private javax.swing.JButton exportjButton;
    private javax.swing.JButton exportjButton2;
    private javax.swing.JPanel helpAuxPanel;
    private javax.swing.JButton helpButton;
    private javax.swing.JButton helpButton2;
    private javax.swing.JTabbedPane helpTabbedPane;
    private javax.swing.JButton importjButton;
    private javax.swing.JButton importjButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JButton partitionjButton;
    private javax.swing.JButton partitionjButton2;
    private javax.swing.JTabbedPane selectorTabbedPane;
    private javax.swing.JToolBar selectorToolBar;
    private javax.swing.JPanel startPanel;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JSplitPane verticalSplitPane;
    private javax.swing.JButton visualizejButton;
    private javax.swing.JButton visualizejButton2;
    private javax.swing.JPanel workPanel;
    // End of variables declaration//GEN-END:variables
    
    /**
     * Help panel
     */
    private HelpContent contenido = new HelpContent();
    
    /**
     * Parent frame
     */
    protected JFrame parent = null;

    /**
     * <p>
     * Sets parent
     * </p>
     * @param parent Frame parent
     */
    public void setParent(JFrame parent) {
        this.parent = parent;
    }

    /**
     * <p>
     * Adds Import Tab
     * @param showInsertKeel Do you want to show the option to include the imported
     *                       files in the experiment section?
     * @param kfold Do you want to "kfold" be the default option for the partition
     *              type when importing partions?
     * </p>
     */
    public void addImportTab(boolean showInsertKeel, boolean kfold) {
        this.statusMessageLabel.setText("This option allows you to import other format files to KEEL format");
        for (int i = 0; i < selectorTabbedPane.getTabCount(); i++) {
            if (selectorTabbedPane.getComponentAt(i) instanceof ImportPanel) {
                selectorTabbedPane.setSelectedIndex(i);
                return;
            }
        }
        ImportPanel importPanel = new ImportPanel();
        importPanel.setShowInsertKeel(showInsertKeel);
        importPanel.setKfold(kfold);
        importPanel.setParent(this);
        importPanel.setDataCFView(this);
        selectorTabbedPane.add(importPanel, "Import    ");
        selectorTabbedPane.setSelectedComponent(importPanel);
        selectorTabbedPane.setTabComponentAt(selectorTabbedPane.getSelectedIndex(), new ButtonTabComponent(selectorTabbedPane));
    }

    /**
     * <p>
     * Adds Export Tab
     * </p>
     */
    public void addExportTab() {
        this.statusMessageLabel.setText("This option allows you to export KEEL format files to other formats");
        for (int i = 0; i < selectorTabbedPane.getTabCount(); i++) {
            if (selectorTabbedPane.getComponentAt(i) instanceof ExportPanel) {
                selectorTabbedPane.setSelectedIndex(i);
                return;
            }
        }
        ExportPanel exportPanel = new ExportPanel();
        exportPanel.setParent(this);
        selectorTabbedPane.add(exportPanel, "Export    ");
        selectorTabbedPane.setSelectedComponent(exportPanel);
        selectorTabbedPane.setTabComponentAt(selectorTabbedPane.getSelectedIndex(), new ButtonTabComponent(selectorTabbedPane));
    }

    /**
     * <p>
     * Adds Visualize Tab
     * </p>
     */
    public void addVisualizeTab() {
        this.statusMessageLabel.setText("This option allows you to visualize existing KEEL format datasets");
        for (int i = 0; i < selectorTabbedPane.getTabCount(); i++) {
            if (selectorTabbedPane.getComponentAt(i) instanceof VisualizePanel) {
                selectorTabbedPane.setSelectedIndex(i);
                return;
            }
        }
        VisualizePanel visualizePanel = new VisualizePanel();
        visualizePanel.setParent(this);
        selectorTabbedPane.add(visualizePanel, "Visualize ");
        selectorTabbedPane.setSelectedComponent(visualizePanel);
        selectorTabbedPane.setTabComponentAt(selectorTabbedPane.getSelectedIndex(), new ButtonTabComponent(selectorTabbedPane));
    }

    /**
     * <p>
     * Adds Edit Tab
     * </p>
     */
    public void addEditTab() {
        this.statusMessageLabel.setText("This option allows you to edit existing KEEL format datasets");
        for (int i = 0; i < selectorTabbedPane.getTabCount(); i++) {
            if (selectorTabbedPane.getComponentAt(i) instanceof EditPanel) {
                selectorTabbedPane.setSelectedIndex(i);
                return;
            }
        }
        EditPanel editPanel = new EditPanel();
        editPanel.setParent(this);
        editPanel.setDataCFView(this);
        selectorTabbedPane.add(editPanel, "Edit      ");
        selectorTabbedPane.setSelectedComponent(editPanel);
        selectorTabbedPane.setTabComponentAt(selectorTabbedPane.getSelectedIndex(), new ButtonTabComponent(selectorTabbedPane));
    }

    /**
     * <p>
     * Adds Edit Tab
     * </p>
     */
    public void addEditTab(File file) {
        this.statusMessageLabel.setText("This option allows you to edit existing KEEL format datasets");
        for (int i = 0; i < selectorTabbedPane.getTabCount(); i++) {
            if (selectorTabbedPane.getComponentAt(i) instanceof EditPanel) {
                selectorTabbedPane.setSelectedIndex(i);
                EditPanel editPanel =
                        (EditPanel) selectorTabbedPane.getComponentAt(i);
                editPanel.loadFile(file, true);
                return;
            }
        }
        EditPanel editPanel = new EditPanel();
        editPanel.setParent(this);
        editPanel.setDataCFView(this);
        editPanel.loadFile(file, true);
        selectorTabbedPane.add(editPanel, "Edit      ");
        selectorTabbedPane.setSelectedComponent(editPanel);
        selectorTabbedPane.setTabComponentAt(selectorTabbedPane.getSelectedIndex(), new ButtonTabComponent(selectorTabbedPane));
    }

    /**
     * <p>
     * Adds Partition Tab
     * </p>
     */
    public void addPartitionTab() {
        this.statusMessageLabel.setText("This option allows you to make partitions of existing KEEL datasets");
        for (int i = 0; i < selectorTabbedPane.getTabCount(); i++) {
            if (selectorTabbedPane.getComponentAt(i) instanceof PartitionPanel) {
                selectorTabbedPane.setSelectedIndex(i);
                return;
            }
        }
        PartitionPanel partitionPanel = new PartitionPanel();
        partitionPanel.setParent(this);
        selectorTabbedPane.add(partitionPanel, "Partition ");
        selectorTabbedPane.setSelectedComponent(partitionPanel);
        selectorTabbedPane.setTabComponentAt(selectorTabbedPane.getSelectedIndex(), new ButtonTabComponent(selectorTabbedPane));
    }

    /**
     * <p>
     * Adds Partiton Tab
     * @param file File to partition
     * </p>
     */
    public void addPartitionTab(File file) {
        this.statusMessageLabel.setText("This option allows you to make partitions of existing KEEL datasets");
        for (int i = 0; i < selectorTabbedPane.getTabCount(); i++) {
            if (selectorTabbedPane.getComponentAt(i) instanceof PartitionPanel) {
                selectorTabbedPane.setSelectedIndex(i);
                PartitionPanel partitionPanel =
                        (PartitionPanel) selectorTabbedPane.getComponentAt(i);
                partitionPanel.getFileBrowserPanel().getFileChooser().setCurrentDirectory(file);
                partitionPanel.getFileBrowserPanel().getFileChooser().setSelectedFile(file);
                return;
            }
        }
        PartitionPanel partitionPanel = new PartitionPanel();
        partitionPanel.setParent(this);
        partitionPanel.getFileBrowserPanel().getFileChooser().setCurrentDirectory(file);
        partitionPanel.getFileBrowserPanel().getFileChooser().setSelectedFile(file);
        selectorTabbedPane.add(partitionPanel, "Partition ");
        selectorTabbedPane.setSelectedComponent(partitionPanel);
        selectorTabbedPane.setTabComponentAt(selectorTabbedPane.getSelectedIndex(), new ButtonTabComponent(selectorTabbedPane));
    }

    /**
     * <p>
     * Shows help
     * </p>
     */
    public void help() {

        this.statusMessageLabel.setText("This option shows a complete manual of the application");
        // Show help
        HelpFrame ayuda = new HelpFrame();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = ayuda.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        ayuda.setLocation((screenSize.width - frameSize.width) / 2,
                (screenSize.height - frameSize.height) / 2);
        ayuda.setVisible(true);
    }

    /**
     * <p>
     * Returns Selector ToolBar
     * @return Selector ToolBar
     * </p>
     */
    public JToolBar getSelectorToolbar() {
        return selectorToolBar;
    }

    /**
     * <p>
     * Returns Selector Tabbed Pane
     * @return Tabbed Pane
     * </p>
     */
    public JTabbedPane getSelectorTabbedPane() {
        return selectorTabbedPane;
    }
}

